package com.ruoyi.task.domain;


import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.task.domain.entity.DataTaskEntity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 测试任务查询
 */
public class DataTaskResp implements Serializable {
    private static final long serialVersionUID = 1L;

    private DataTaskEntity taskInfo;

    /**
     * 照片链接
     */
    private List<String> imageUrlList = new ArrayList<>();

    /**
     * 照片缩放图lmjp
     */
    private List<String> imageScaleUrlList = new ArrayList<>();

    /***
     * 视频链接
     */
    private List<String> videoUrlList = new ArrayList<>();

    /**
     * 视频缩放图链接
     */
    private List<String> videoScaleUrlList = new ArrayList<>();


    public DataTaskResp(DataTaskEntity dataTaskEntity) {
        this.taskInfo = dataTaskEntity;
        if (dataTaskEntity != null) {
            this.getImgMediaUrl(dataTaskEntity.getImgNames());
            this.getVideoMediaUrl(dataTaskEntity.getVideoNames());
        }
    }

    public void getImgMediaUrl(String imgNames) {

        if (!StringUtils.isEmpty(imgNames)) {
            String[] imgArray = imgNames.split("&");
            for (int i = 0; i < imgArray.length; i++) {
                this.imageUrlList.add(RuoYiConfig.getMediaPath() + "/" + imgArray[i]);
                this.imageScaleUrlList.add(RuoYiConfig.getMediaPath() + "/" + imgArray[i].replace(".jpg","-scale.jpg"));
            }
        }
    }

    public void getVideoMediaUrl(String videoNames) {
        if (!StringUtils.isEmpty(videoNames)) {
            String[] videoArray = videoNames.split("&");
            for (int i = 0; i < videoArray.length; i++) {
                this.videoUrlList.add(RuoYiConfig.getMediaPath() + "/" + videoArray[i]);
                this.videoScaleUrlList.add(RuoYiConfig.getMediaPath() + "/" + videoArray[i].replace(".mp4","-scale.jpg"));
            }
        }
    }

    public DataTaskEntity getTaskInfo() {
        return taskInfo;
    }

    public void setTaskInfo(DataTaskEntity taskInfo) {
        this.taskInfo = taskInfo;
    }

    public List<String> getImageUrlList() {
        return imageUrlList;
    }

    public void setImageUrlList(List<String> imageUrlList) {
        this.imageUrlList = imageUrlList;
    }

    public List<String> getImageScaleUrlList() {
        return imageScaleUrlList;
    }

    public void setImageScaleUrlList(List<String> imageScaleUrlList) {
        this.imageScaleUrlList = imageScaleUrlList;
    }

    public List<String> getVideoUrlList() {
        return videoUrlList;
    }

    public void setVideoUrlList(List<String> videoUrlList) {
        this.videoUrlList = videoUrlList;
    }

    public List<String> getVideoScaleUrlList() {
        return videoScaleUrlList;
    }

    public void setVideoScaleUrlList(List<String> videoScaleUrlList) {
        this.videoScaleUrlList = videoScaleUrlList;
    }
}
